package org.jeecg.common.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * 事件发布器
 * 用于发布应用内事件
 */
@Slf4j
@Component
public class EventPublisher {
    
    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;
    
    /**
     * 发布领料单出库事件
     * 
     * @param event 领料单出库事件
     */
    public void publishRequisitionOutboundEvent(RequisitionOutboundEvent event) {
        try {
            log.info("发布领料单出库事件: 领料单号={}, 订单号={}, 租户ID={}", 
                    event.getRequisitionNo(), event.getOrderNo(), event.getTenantId());
            applicationEventPublisher.publishEvent(event);
        } catch (Exception e) {
            log.error("发布领料单出库事件失败", e);
        }
    }
}
